package Homework5;

public class Triangle extends GeometricObject{
    private double side1, side2, side3;

    public Triangle(){
        side1 = 1.0;
        side2 = 1.0;
        side3 = 1.0;
    }

    public Triangle(double side1, double side2, double side3){
        if (((side1 + side1) > side3) && ((side1 + side3) > side2) && ((side2 + side3) > side1)){
            this.side1 = side1;
            this.side2 = side2;
            this.side3 = side3;
        }else {
            this.side1 = 1.0;
            this.side2 = 1.0;
            this.side3 = 1.0;
        }
    }

    public double getSide1() {
        return side1;
    }

    public double getSide3() {
        return side3;
    }

    public double getSide2() {
        return side2;
    }

    public double getArea(){
        double c,s;
        c = this.getPerimeter() / 2;
        s = Math.sqrt(c * (c - side1) * (c - side2) * (c - side3));
        return s;
    }

    public double getPerimeter(){
        return side1 + side2 + side3;
    }

    @Override
    public String toString(){
        return "Triangle: side1 = " + side1 + " side2 = " + side2 + " side3 = " + side3 +  " color = " + getColor() + " fiiled = " + isFilled();
    }
}
